﻿// Decompiled with JetBrains decompiler
// Type: DnProcessSimulateCommands.ModularFixture.CApMFConfigurationData
// Assembly: DnProcessSimulateCommands, Version=2402.0.0.890, Culture=neutral, PublicKeyToken=null
// MVID: A885D881-AEDF-447E-852A-6F13102E089C
// Assembly location: C:\Program Files\Tecnomatix_2402\eMPower\DotNetCommands\DnProcessSimulateCommands.dll

using EMPAPPSERVICESLib;
using EMPMODELLib;
using EMPTYPELIBRARYLib;
using Tecnomatix.Engineering;


namespace DnProcessSimulateCommands.ModularFixture;

internal class CApMFConfigurationData
{
  private string m_name;
  protected string m_bitmapFile;
  private int m_internalId;
  private TxTransformation m_location;

  internal CApMFConfigurationData(string name, string bitmap)
  {
    this.m_name = name;
    this.m_bitmapFile = bitmap;
    this.m_location = new TxTransformation();
  }

  internal CApMFConfigurationData(string name)
  {
    this.m_name = name;
    this.m_location = new TxTransformation();
  }

  internal void SaveCommonAttributesToEms(int internalId, string configType)
  {
    (TxApplication.ActiveDocument.PlatformGlobalServicesProvider as TxEmsGlobalServicesProvider).GetObjectByInternalId(internalId);
    EmpContext empContext;
    empContext.sessionId = TxApplication.ActiveDocument.eMSSessionId;
    EmpFieldValue[] empFieldValueArray = new EmpFieldValue[1];
    empFieldValueArray[0].fieldName = "ConfigurationType";
    empFieldValueArray[0].FieldValue = (object) configType;
    EmpNodeFieldsValues[] nodeFieldsValuesArray = new EmpNodeFieldsValues[1]
    {
      new EmpNodeFieldsValues()
      {
        Node = {
          objectId = internalId
        },
        FieldsValues = empFieldValueArray
      }
    };
    ((IEmpNodesServices) new EmpNodesServicesClass()).SetFields(ref empContext, ref nodeFieldsValuesArray);
    if (!(this.m_bitmapFile != ""))
      return;
    ((IEmpToolPrototype) new EmpToolPrototypeClass()).CreateImage(ref empContext, ref new EmpObjectKey()
    {
      objectId = internalId
    }, this.m_bitmapFile);
  }

  internal void LoadCommonAttributesFromEms(int internalId)
  {
    EmpContext empContext;
    empContext.sessionId = TxApplication.ActiveDocument.eMSSessionId;
    EmpObjectKey image = ((IEmpToolPrototype) new EmpToolPrototypeClass()).GetImage(ref empContext, ref new EmpObjectKey()
    {
      objectId = internalId
    });
    EmpPictureClass empPictureClass = new EmpPictureClass();
    if (image.objectId == 0)
      return;
    this.m_bitmapFile = empPictureClass[ref empContext, ref image];
  }

  internal virtual void SaveAttributesToEms(int internalId)
  {
  }

  internal virtual void LoadAttributesFromEms(int internalId)
  {
  }

  internal string Name
  {
    get => this.m_name;
    set => this.m_name = value;
  }

  internal string BitmapFile
  {
    get => this.m_bitmapFile;
    set => this.m_bitmapFile = value;
  }

  internal int InternalId
  {
    set => this.m_internalId = value;
  }
}
